# -*- coding: utf-8 -*-

import os,sys, wx 


class Frame(wx.Frame):
    def __init__(self,parent ,id ,title ):
        print "Frame__init___"
        wx.Frame.__init__(self,parent,id,title)
        
           
class App(wx.App): 
    def __init__(self,redirect=True,filename=None):
        print "App __init__"
        wx.App.__init__(self,redirect,filename)
           
    def OnInit(self): 
        print "OnInit"
        self.frame = Frame(parent=None,id=-1,title='Startup')#创建\
        
        #myid = self.frame.GetId()

        self.frame.Show()
        #self.frame.Close() #关闭框架
        
        """SetExitOnFrameDelete(flag)"""
        #---------
        # ExitMainLoop()
                #wx.Exit()#关闭wx程序

        self.SetTopWindow(self.frame)
        print >> sys.stderr,"Apretend error message" #输出到stdout
        return True
    def OnExit(self):
        print "OnExit"
        
if __name__ == '__main__':
    app = App(redirect=True)
    #app = App(redirect=True,filename=os.path.dirname(__file__)+'/out.txt')
    print "before MainLoop"
    app.MainLoop()#2进入主事件
    print "aftre MainLoop"
    
         
        
        
"""
wx.EVT_QUERY_END_SESSION  事件

wx.CloseEvent

CanVeto()
wx.EVT_CLOSE  事件

"""


        
        
        
        
        
        